/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package controller;

import javax.microedition.lcdui.Image;

/**
 *
 * @author efraeli
 */
public class ScreenController extends ButtonController {
    public final static int BUTTON_ID_SCREEN_ZOOM_IN    = 1;
    public final static int BUTTON_ID_SCREEN_ZOOM_OUT   = 2;
    public final static int BUTTON_ID_SCREEN_ROTATE     = 3;
    public final static int BUTTON_ID_SCREEN_MOVE_LEFT  = 4;
    public final static int BUTTON_ID_SCREEN_MOVE_RIGHT = 5;
    public final static int BUTTON_ID_SCREEN_MOVE_UP    = 6;
    public final static int BUTTON_ID_SCREEN_MOVE_DOWN  = 7;
    private int zoomValue=0;
    private int screenPosX=0;
    private int screenPosY=0;

    public ScreenController(int initialPosX, int initialPosY) {
        try {
            this.addButton(new ImageButton(BUTTON_ID_SCREEN_ZOOM_IN,
                    initialPosX-30, 0,
                    Image.createImage("/sound_plus.png"),
                    Image.createImage("/sound_mute.png"),
                    Image.createImage("/sound_minus.png")));
            this.addButton(new ImageButton(BUTTON_ID_SCREEN_ZOOM_OUT,
                    initialPosX-60, 0,
                    Image.createImage("/sound_plus.png"),
                    Image.createImage("/sound_mute.png"),
                    Image.createImage("/sound_minus.png")));
            this.addButton(new ImageButton(BUTTON_ID_SCREEN_ROTATE,
                    initialPosX-90, 0,
                    Image.createImage("/sound_plus.png"),
                    Image.createImage("/sound_mute.png"),
                    Image.createImage("/sound_minus.png")));
        } catch (Throwable ex) {
            ex.printStackTrace();
        }

    }

    public int selected() {
        int buttonId = super.selected();
        if(buttonId == BUTTON_ID_SCREEN_ZOOM_IN) {
            if(zoomValue!=8) zoomValue++;
        } else if(buttonId == BUTTON_ID_SCREEN_ZOOM_OUT) {
            if(zoomValue!=0) zoomValue--;
        } else if(buttonId == BUTTON_ID_SCREEN_MOVE_DOWN) {
            screenPosY -=5;
        } else if(buttonId == BUTTON_ID_SCREEN_MOVE_UP) {
            screenPosY +=5;
        } else if(buttonId == BUTTON_ID_SCREEN_MOVE_LEFT) {
            screenPosX -=5;
        } else if(buttonId == BUTTON_ID_SCREEN_MOVE_RIGHT) {
            screenPosX +=5;
        }
        return buttonId;
    }

    public int getZoomValue() {
        return zoomValue;
    }

    public int getScreenPosX() {
        return screenPosX;
    }

    public int getScreenPosY() {
        return screenPosY;
    }

}
